import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.concurrent.PriorityBlockingQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-03-25
 * Time: 20:23
 */

class createA {
    public static A createA1(int a) {
        //匿名内部类优先捕获全局性质变量，这里在代码块内，a1就为全局性变量~
        return new A() {
            {
                this.a1 = a;
            }
        };
    }
    public static A createA2(int a) {
        return new A() {
            {
                this.a2 = a;
            }
        };
    }
    public static A createA3(int a) {
        return new A() {
            {
                this.a3 = a;
            }
        };
    }
    public static A createA4(int a) {
        return new A() {
            {
                this.a4 = a;
            }
        };
    }
    public static A createA5(int a) {
        return new A() {
            {
                this.a5 = a;
            }
        };
    }
    public static A createA6(int a) {
        return new A() {
            {
                this.a6 = a;
            }
        };
    }
}


public class A {
    int a1;
    int a2;
    int a3;
    int a4;
    int a5;
    int a6;
    //参数列表相同无法特定构造特定成员~



    @Override
    public String toString() {
        return "A{" +
                "a1=" + a1 +
                ", a2=" + a2 +
                ", a3=" + a3 +
                ", a4=" + a4 +
                ", a5=" + a5 +
                ", a6=" + a6 +
                '}' + '\n';
    }

    public static void main(String[] args) {
        PriorityQueue<A> queue1 = new PriorityQueue<>(CreateComparatorA.createA1());
        PriorityQueue<A> queue2 = new PriorityQueue<>(CreateComparatorA.createA2());
        PriorityQueue<A> queue3 = new PriorityQueue<>(CreateComparatorA.createA3());
        PriorityQueue<A> queue4 = new PriorityQueue<>(CreateComparatorA.createA4());
        PriorityQueue<A> queue5 = new PriorityQueue<>(CreateComparatorA.createA5());
        PriorityQueue<A> queue6 = new PriorityQueue<>(CreateComparatorA.createA6());

        queue1.offer(createA.createA1(2));
        queue1.offer(createA.createA1(1));
        queue1.offer(createA.createA1(4));
        queue1.offer(createA.createA1(3));
        queue1.offer(createA.createA1(5));

        System.out.println(queue1);

    }
}
class ComparatorA implements Comparator<A> {
    @Override
    public int compare(A o1, A o2) {
        return o1.a1 - o2.a1;
    }
}



class CreateComparatorA {
    public static Comparator<A> createA1() {
        return ((o1, o2) -> {
           return o1.a1 - o2.a1;
        });
    }
    public static Comparator<A> createA2() {
        return ((o1, o2) -> {
           return o1.a2 - o2.a2;
        });
    }
    public static Comparator<A> createA3() {
        return ((o1, o2) -> {
           return o1.a3 - o2.a3;
        });
    }
    public static Comparator<A> createA4() {
        return ((o1, o2) -> {
           return o1.a4 - o2.a4;
        });
    }
    public static Comparator<A> createA5() {
        return ((o1, o2) -> {
           return o1.a5 - o2.a5;
        });
    }
    public static Comparator<A> createA6() {
        return ((o1, o2) -> {
           return o1.a6 - o2.a6;
        });
    }
}